package model;

import java.util.Date;
import java.util.UUID;

import common.Enums.MethodType;
import common.Enums.ReliabilityType;
import common.Enums.SourceType;

public class Value 
{
	private boolean hasError;
	private UUID ID;
	private String unit;
	private String source;
	protected String stringResult;
	private MethodType type;
	private SourceType sourceType;
	private ReliabilityType reliability;
	private Date createdDate;
	private Date lastUpdated;
	
	public Value(MethodType type)
	{
		ID = UUID.randomUUID();
		this.type = type;
	}
	
	public Value(MethodType type, UUID ID)
	{
		this.ID = ID;
		this.type = type;
	}
	
	public boolean getHasError() {
		return hasError;
	}

	public void setHasError(boolean hasError) {
		this.hasError = hasError;
	}

	public MethodType getType() {
		return type;
	}
	
	public void setType(MethodType type)
	{
		this.type = type;
	}
	
	public String getUnit() {
		return unit;
	}

	public void setUnit(String unit) {
		this.unit = unit;
	}

	public String getSource() {
		return source;
	}

	public void setSource(String source) 
	{
		this.source = source;
	}

	public SourceType getSourceType() {
		return sourceType;
	}

	public void setSourceType(SourceType sourceType) {
		this.sourceType = sourceType;
	}

	public ReliabilityType getReliability() {
		return reliability;
	}

	public void setReliability(ReliabilityType reliability) {
		this.reliability = reliability;
	}
	
	public UUID getID()
	{
		return ID;
	}

	public Date getCreatedDate() {
		return createdDate;
	}

	public void setCreatedDate(Date createdDate) {
		this.createdDate = createdDate;
	}

	public Date getLastUpdated() {
		return lastUpdated;
	}

	public void setLastUpdated(Date lastUpdated) {
		this.lastUpdated = lastUpdated;
	}
	
	/* GAMI: Was necessary because the class cannot be abstract otherwise the Gson won't be able to parse the class to its actual Json object. */
	
	public String getStringResult() 
	{
		return stringResult;
	}
	
	public void setStringResult(String newResult)
	{
		stringResult = newResult;
	}
	
	/*************** END GAMBI ****************/
	
	
	@Override
	public boolean equals(Object obj) 
	{
		boolean equals = false;
		
		if(obj.getClass() == this.getClass())
			equals = (ID.equals(((Value)obj).getID()));
		
		return equals;
	}
	
	@Override
	public int hashCode() 
	{
		return ID.hashCode();
	}
}
